package fun.rockchen.dao;

import fun.rockchen.bean.MapTaskEntity;
import fun.rockchen.bean.User;
import fun.rockchen.bean.UserMapTag;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Rock Chen
 * @Description:
 * @date 2023/10/15 19:22
 */

@Mapper
public interface UserDao {
    @Select("select * from user where phoneNum = '${phoneNum}'")
    User getInfoByPhoneNum(User user);

    @Insert("insert into user (id, userName, password, phoneNum) values(#{id}, #{userName}, #{password}, #{phoneNum})")
    boolean addUser(User user);

    @Delete("delete userMapTask,user,task from userMapTask left join user on user.id = userMapTask.userId left join task on userMapTask.taskId = task.id where user.id= '${id}'")
    boolean deleteUser(MapTaskEntity mapTaskEntity);

    @Update("update user set tag = '${options}' where id = '${id}'")
    boolean updateUserTag(MapTaskEntity mapTaskEntity);

    @Select("select tag.tagContent from tag" +
            "    inner join userMapTag on tagId = tag.id " +
            "where userId = '${id}'")
    List<String> getUserTag(String id);

    @Insert("insert into userMapTag (userId, tagId) values ('${userId}', '${tagId}')")
    boolean addUserTag(UserMapTag userMapTag);

}
